﻿<cfsilent>
	<cfscript>
		
		event.setArg("pageTitle", "教学运行管理 - 学期课程安排");
		
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		
		termId = event.getArg("TID");

		sql = "SELECT 
					t.term_id, 
					t.academic_year, 
					t.academic_term, 
					t.term_prop 
				FROM 
					t_term t 
				WHERE 
					t.term_id = :termId ";
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		
		rs_term = queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT 
					COUNT(*) task_count, 
					COUNT(DISTINCT c.cid) course_count, 
					SUM(b.period_need) period_need_sum, 
					SUM(CASE WHEN b.period_done > b.period_need THEN b.period_need ELSE b.period_done END) period_done_sum, 
					b.task_type 
					FROM t_task_arrange b 
						INNER JOIN t_course c ON c.cid = b.cid 
					WHERE 
						b.term_id = :termId 
						AND 
						( 
							EXISTS(SELECT 1 FROM t_task t WHERE t.tsk_id = b.task_id AND SUBSTR(t.task_prop,7,1) = '0') 
							OR 
							EXISTS(SELECT 1 FROM t_common_task t WHERE t.tsk_id = b.task_id AND SUBSTR(t.task_prop,7,1) = '0') 
							OR 
							EXISTS(SELECT 1 FROM t_reopen_task t WHERE t.tsk_id = b.task_id AND SUBSTR(t.task_prop,7,1) = '0') 
							OR 
							EXISTS(SELECT 1 FROM t_sport_task t WHERE t.tsk_id = b.task_id AND SUBSTR(t.task_prop,7,1) = '0') 
						) 
						AND 
						b.period_need > 0 
					GROUP BY 
						b.task_type 
					ORDER BY 
						SUM(b.period_need) DESC";
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		
		rs_type = queryObj.execute( sql=sql ).getResult();
		
		passArgs = structNew();
		
		structInsert( passArgs, "TID", termId, true );
		
		currentTab = event.getArg("Tab", "labSummary");
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 course"></i><cfoutput>#rs_term.academic_year#</cfoutput> 学年 - <cfoutput>#dictAdvice.getTerm(rs_term.academic_term)#</cfoutput> 课程安排
				</h2>
			</div>
		</div>
	</div>
</div>

<!--- 加载导航菜单 --->
<!-- stepMenu-->
<cfoutput>#event.getArg("stepMenu")#</cfoutput>
<!--/stepMenu-->


<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				
				<div class="UItab2">
					<div class="tabLables">
						<span <cfif currentTab eq "labSummary">class="active"</cfif> id="labSummary" tabTarget="Summary">教学安排总览</span>
						<span <cfif currentTab eq "labSystem">class="active"</cfif> id="labSystem" tabTarget="System">系统数据</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="Summary" class="tabContent">
				
					<div class="noticeBlock">
						<h3>学期教学任务概况</h3>
						<hr/>
					</div>
					
					<div class="clearfix">
						<ul class="UIDashBoard">
							<cfset i = 0 />
							<cfloop query="rs_type">
								<cfset i++ />
	
								<cfswitch expression="#rs_type.task_type#">
									<cfcase value="P"><cfset targetEvent = "planTask"/></cfcase>
									<cfcase value="C"><cfset targetEvent = "commonTask"/></cfcase>
									<cfcase value="R"><cfset targetEvent = "openTask"/></cfcase>
									<cfcase value="T"><cfset targetEvent = "sportTask"/></cfcase>
								</cfswitch>
								
								<cfset prog = min( 100, 100 * rs_type.period_done_sum/rs_type.period_need_sum ) />
								<cfset progL = 1 />
								<cfif prog gt 0 and prog lte 25><cfset progL = 2 /></cfif>
								<cfif prog gt 25 and prog lte 50><cfset progL = 3 /></cfif>
								<cfif prog gt 50 and prog lte 75><cfset progL = 4 /></cfif>
								<cfif prog gt 75 and prog lte 100><cfset progL = 5 /></cfif>
	
								<li class="col2 <cfif i mod 2 eq 0>last</cfif>">
									<div class="board hasPic">
										<a href="<cfoutput>#buildURL(targetEvent, passArgs)#</cfoutput>">
											<div class="pic">
												<span class="icon64x64 tasktype<cfoutput>#rs_type.task_type#</cfoutput>"></span>
											</div>
											<div class="content">
												<h3><cfoutput>#numberFormat(rs_type.period_need_sum, "___,___,___,___")#</cfoutput><span class="unitPriod">学时</span></h3>
												<cfswitch expression="#rs_type.task_type#">
													<cfcase value="P"><h5>计划课程</h5></cfcase>
													<cfcase value="C"><h5>全校性通选课</h5></cfcase>
													<cfcase value="R"><h5>单开班任务</h5></cfcase>
													<cfcase value="T"><h5>体育项目</h5></cfcase>
												</cfswitch>
												<p class="describ">
													学期排课计划:
													开课<span class="smallNum"><cfoutput>#rs_type.course_count#</cfoutput></span>门, 
													计划开设<span class="smallNum"><cfoutput>#rs_type.task_count#</cfoutput></span>个教学班
												</p>
												<p class="describ">
													课程安排进度 <span class="iconProg L<cfoutput>#progL#</cfoutput>"></span> <span class="smallNum"><cfoutput>#numberformat(prog, "__._")#</cfoutput>%</span> 
												</p>
											</div>
										</a>
									</div>
								</li>
								
								<cfif i mod 2 eq 0>
									<div class="clearfix"><!--.--></div>
								</cfif>
								
							</cfloop>
						</ul>
					</div>
				
				</div>
				
				<div id="System" class="tabContent">
					
					<div class="noticeBlock">
						<h3>重新计算排课数据</h3>
						<hr/>
					</div>
					
					<div class="clearfix">
						<ul class="UINavBoard">
							<li class="col3 first">
								<div class="board hasPic">
									<a href="<cfoutput>#buildURL('rebuildTeacherTimeTable', passArgs)#</cfoutput>">
										<div class="pic">
											<span class="icon48x48 teacherCourseTable"></span>
										</div>
										<div class="content">
											<h5>重建教师时间占用表</h5>
											<p>重新计算指定学期, 教师上课时间占用数据</p>
										</div>
									</a>
								</div>
							</li>
						</ul>
					</div>
					
				</div>

			</div>
		</li>
	</ul>
</div>